<?php
/**
 * Created by PhpStorm.
 * User: skytop
 * Date: 16-8-29
 * Time: 下午7:13
 */

namespace Admin\Controller;

use Think\Controller;
class AttributeController extends Controller
{
    //添加属性
    public function index(){
        $attrTable=M('attr');
        $this->list=$attrTable->select();
        $this->display();
    }

    //添加属性视图
    public function addAttr(){
        if(IS_POST){
            print_r(I());
            $data=array(
                'name'=>I('post.name'),
                'color'=>I('post.color')
            );

            $attrTable=D('attr');
            if($attrTable->create($data)){
                $attrTable->add();
                $this->success('添加属性成功!',U('Attribute/index'));
            }else{
                $this->error($attrTable->getError());
            }
        }else {
            $this->display();
        }
    }
}